import request from "@/utils/request"

//品牌列表中每一个品牌的具体类型
export interface trademarkItemType {
  id?: number
  tmName: string
  logoUrl: string
}

//品牌列表的数组类型
export type trademarkLitsType = trademarkItemType[]

//品牌分页列表的返回值类型
export interface trademarkListReturnType {
  records: trademarkLitsType //品牌列表数据
  total: number //总条数
  size: number //每页条数
  current: number //当前页
  searchCount: boolean
  pages: number //总页数
}

//1.请求品牌分页列表数据
export const reqTrademarkList = (page: number, limit: number) => {
  return request.get<null, trademarkListReturnType>(
    `/admin/product/baseTrademark/${page}/${limit}`
  )
}

//2.新增品牌的请求
export const reqAddTrademark = (tradeInfo: trademarkItemType) => {
  return request.post<null, null>(
    `/admin/product/baseTrademark/save`,
    tradeInfo
  )
}

//3.修改品牌的请求
export const reqUpdateTrademark = (tradeInfo: trademarkItemType) => {
  return request.put<null, null>(
    `/admin/product/baseTrademark/update`,
    tradeInfo
  )
}

//4.删除品牌的请求
export const reqDeleteTrademark = (id: number) => {
  return request.delete<null, null>(`/admin/product/baseTrademark/remove/${id}`)
}

//5.获取所有品牌的请求
export const reqAllTrademark = () => {
  return request.get<null, trademarkLitsType>(
    `/admin/product/baseTrademark/getTrademarkList`
  )
}
